package com.ry.novel.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ry.novel.model.dto.ReportInfo;
import com.ry.novel.model.dto.condition.ReportQuery;
import com.ry.novel.model.resp.Result;
import com.ry.novel.service.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ry
 * @since 2022-04-08 23:08
 **/
@RequestMapping("/report")
@RestController
public class ReportController {
    @Autowired
    private ReportService reportService;

    @PostMapping("/queryReport")
    public Result<Page<ReportInfo>> queryReport(@RequestBody ReportQuery reportQuery){
        Page<ReportInfo> page = reportService.queryReport(reportQuery);

        return Result.ok(page);
    }

    @PostMapping("/addReport")
    public Result<Void> addReport(@RequestBody ReportInfo reportInfo){
        System.out.println(reportInfo);
        reportService.addReport(reportInfo);

        return Result.ok();
    }

    @PostMapping("/updateReport")
    public Result<Void> updateReport(@RequestBody ReportInfo reportInfo){
        reportService.updateReport(reportInfo);

        return Result.ok();
    }

    @PostMapping("/deleteReport")
    public Result<Void> deleteReport(@RequestParam("id") Long id){
        reportService.deleteReport(id);

        return Result.ok();
    }
}
